Course Outline

The objective of the course is to present linear and non-linear models for both conditional mean and conditional variances. The Extreme Values Theory, Theory of Copulas and Additional Topics (Models for High Frequency Data, Continuous Time Modelsor High Dimensional Model) will also be presented.

Stylized Facts in Financial Data

Primeiro, iremos buscar as bases de dados, sendo c("^IXIC","AAPL") o índice NASDAQ e a ação da Apple, respectivamente:

options(scipen=999)
library(tidyquant)
library(tidyverse)
library(plotly)
df <- tq_get(c("^BVSP","BBAS3.SA"), get = "stock.prices", from = "2016-01-01", complete_cases = FALSE)

Faremos então o Retorno Simples e Retorno Composto e para o fechamento do dia (Close):

ts <- df |> 
  group_by(symbol) |> 
  summarise(date = date, 
            close = close , 
            lClose = log(close), 
            rsClose = ((close-Lag(close))/Lag(close))*100,
            rcClose = (lClose - Lag(lClose))*100
              )

pl1 <- ts |> group_by(symbol) |>
    ggplot(aes(x = date, y = rsClose, color = symbol)) +
    geom_line(size = 0.5) +
    scale_y_continuous() +
    labs(title = "Retorno Simples",
         x = "", y = "Retorno", color = "") +
    facet_wrap(~ symbol, nrow = 2, scales = "free_y") +
    theme_tq() 
ggplotly(pl1)
pl2 <- ts |> group_by(symbol) |>
    ggplot(aes(x = date, y = rcClose, color = symbol)) +
    geom_line(size = 0.5) +
    scale_y_continuous() +
    labs(title = "Retorno Composto",
         x = "", y = "Retorno", color = "") +
    facet_wrap(~ symbol, nrow = 2, scales = "free_y") +
    theme_tq() 

ggplotly(pl2)

As duas metodólogias de retorno são usadas para estacionarizar a série, podemos perceber que

Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Cmd+Option+I.

When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Cmd+Shift+K to preview the HTML file).

The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.